using System;
using System.Collections.Generic;
using System.Text;
using ImagesMath;

namespace Graphics.Geometries
{
    public class Plane : Form
    {

        public Plane(): base()
        {

        }

        public override bool FirstIntersection(ref Ray  ray,ref Intersection inter )
        {
            double Zo = ray.Origin.Z;  
            double Zd = ray.Direction.Z;

             if (Zd !=0)
                {
                 inter.T =  -(Zo) / (Zd);
                 if (inter.T > ImageMath.EPS) 
                    return true;
                 else 
                    return false;
                 } 
            else 
                 return false;	
        }


        public override VR3 Normal(PR3 p, ref Ray ray)
        {
            return new VR3(0,0,1);
        }
    }

    //class CPlane : public CForm // Plan (0,x,y)
    //{
    //    public:

    //        CPlane() : CForm() {}

    //        bool FirstIntersection( const CRay & ray, CIntersection & inter );
    //        vR3  Normal( const pR3 & p, const CRay & ray );
    //        bool IsInside( const pR3 & p );
    //        string getName()const;
    //        void setName(string name);		
    //};

    //bool CPlane::FirstIntersection( const CRay & ray, CIntersection & inter )
    //{

    //    double Zo = ray.Origin().z;  
    //    double Zd = ray.Direction().z;

    //     if (Zd !=0)
    //        {
    //         inter.t =  -(Zo) / (Zd);	
    //         if (inter.t>EPS) 
    //            return true;
    //         else 
    //            return false;
    //         } 
    //    else 
    //         return false;	
    //}


    //vR3  CPlane::Normal( const pR3 & p, const CRay & ray )
    //{
    //    return vR3(0,0,1);
    //}

    //bool CPlane::IsInside( const pR3 & p )
    //{
    //    return true;
    //}
}
